//
// Created by chizuru on 2025/9/2.
//

#include "TransactionCommandBatchWrite.h"
using std::unique_ptr;
using std::make_unique;
using std::pair;
using std::vector;

TransactionCommandBatchWrite::TransactionCommandBatchWrite(CameraDevice& comm, const vector<pair<uint16_t,uint32_t>>& ops, RetryPolicy rp)
    : ITransactionCommand(comm, ops, rp){

}

OperationResult TransactionCommandBatchWrite::execute() {

    vector<unique_ptr<camera_link_bobcat::ICommand>> writeCmds;
    for (auto &p : ops) {
        writeCmds.push_back(make_unique<RegisterWriteCommand>(comm, p.first, p.second, rp, /* captureOriginal = */true));
    }
    return camera_link_bobcat::Invoker::executeWithRollback(writeCmds);
}
